﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pampa.Grid.Core;
using Pampa.Grid.UI.CustomControls;

namespace Pampa.MVC.Fluent.Grid
{
    public class ColumnBuilder<T>
    {
        private CustomGridConfig<T> _customGridConfig;
        private readonly Column _column;
        private readonly CustomGrid _grid;

        public ColumnBuilder(CustomGridConfig<T> customGridConfig, CustomGrid grid, Column column)
        {
            _customGridConfig = customGridConfig;
            _grid = grid;
            _column = column;
        }

        public ColumnBuilder<T> CssClass(string cssClass)
        {
            _column.CssClass = cssClass;
            return this;
        }

        public ColumnBuilder<T> Format(string format)
        {
            _column.Format = format;
            return this;
        }

        public ColumnBuilder<T> IdColumn()
        {
            _grid.SetIdColumn(_column.Field, true);
            return this;
        }

        public ColumnBuilder<T> EnableColumn()
        {
            _grid.SetEnableColumn(_column.Field, true);
            return this;
        }

        public ColumnBuilder<T> NotElegible()
        {
            _column.IsElegible = false;
            return this;
        }

        public ColumnBuilder<T> Hidden()
        {
            _customGridConfig.Grid.SetVisibleColumn(_column.Field, false);
            return this;
        }

        public ColumnBuilder<T> OrderByDescending()
        {
            _customGridConfig.Grid.SetOrderColumn(_column.Field, OrderDirection.Descending);
            return this;
        }

        public ColumnBuilder<T> OrderByAscending()
        {
            _customGridConfig.Grid.SetOrderColumn(_column.Field, OrderDirection.Ascending);
            return this;
        }
    }
}
